home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: *Pointer to Functions(); /* HELP */
- Date: 22 Jan 1996 15:50:51 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan22085051@qcd.lanl.gov>
- References: <4dvrq8$c2c@news.unicomp.net>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: jgore@conline.com's message of 22 Jan 1996 11:18:32 GMT
-
- --text follows this line--
- In article <4dvrq8$c2c@news.unicomp.net> jgore@conline.com
- (Jerry_Gore) writes:
- <snip>
- void InstallTimer0(WORD period,void far (*func)(void));
- <snip>
- void far animate(void) /* I added 'far' for no good reason. */
- { /* It uses that name in InstallTimer0. */
- /* do what ever */
- return;
- }
-
- How do I send InstallTimer0 the pointer to my function animate ???
- I tried:
-
- InstallTimer0(120 , (*animate)());
-
- First, with the far in place, I cannot answer: the code is a syntax
- error in C, and every conformant C compiler has to diagnose it as
- such. I shall assume that the far is missing from both places. After
- the required diagnosis, or if called to compile in a non-conformant
- mode, it can accept the above and do whatever it feels like with it.
-
- The next question you can ask is how do you create a pointer from a
- nonpointer? The most obvious way is to apply the address of `&'
- operator. Did you try that? InstallTimer0(120,&animate) should have
- worked just fine.
-
- But of course, this does not work and neither did anything else!
- What do I do ???
-
- In fact `neither did anything else' is very vague. I could have tried
- to figure out your basic confusion had you shown me what else you
- tried. In any case, InstallTimer0(120,animate) is probably the
- simplest way to do what you want.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-